{% load static %}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{% block title %}{% endblock %}</title>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link href="https://cdn.jsdelivr.net/npm/@fullcalendar/core/main.css" rel="stylesheet">
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
    <link href="{% static 'ProfileApp/css/header.css'%}">
    <link href="{% static 'ProfileApp/css/footer.css' %}" rel="stylesheet">

    <!-- Подключение JavaScript-файлов Bootstrap (перед закрывающимhttps://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.jsся тегом </body>) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

    {% block scripts %}{% endblock %}
    {% block styles %}{% endblock %}
    {% block modals %}{% endblock %}
</head>
<body>
    <header>
        <nav class="navbar navbar-expand-lg navbar-light bg-light">
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                {% if title != 'Профиль' %}
                    <ul class="navbar-nav">
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'index' %}">Главная</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="/about/">О нас</a>
                        </li>
{#                        <li class="nav-item">#}
{#                            <a class="nav-link" href="/contact/">Контакты</a>#}
{#                        </li>#}
                    </ul>
                {% endif %}
                <ul class="navbar-nav ml-auto">
                    {% if not autentic %}
                            <li class="nav-item">
                                <a class="nav-link" href="{% url 'profile:login' %}">Вход</a>
                            </li>
                    {% endif %}
                    {% if autentic %}
                        {% if title == 'Кабинеты' and user.is_teacher %}
                            <li class="nav-item">
                                <button data-toggle="modal" data-target="#addCabinetModal">
                                  Добавить кабинет
                                </button>
                            </li>
                            <div class="modal fade" id="addCabinetModal" tabindex="-1" role="dialog" aria-labelledby="addCabinetModalLabel" aria-hidden="true">
                                <div class="modal-dialog" role="document">
                                    <!-- Здесь можно разместить вашу форму пост-запроса -->
                                    <form method="post" action="{% url 'profile:profile_cabinet' user.id %}">
                                        {% csrf_token %}
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <h5 class="modal-title" id="addCabinetModalLabel">Добавить кабинет</h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                {{ form.as_p }}
                                            </div>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Закрыть</button>
                                                <button type="submit" class="btn btn-success">Добавить</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        {% endif %}
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'profile:logout' %}">Выход</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'profile:updateViews' user.id %}">Profile</a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </nav>
    </header>
    <main>
        {% block content %}{% endblock %}
    </main>

{% block script %}{% endblock %}
    <footer>
        <!-- Футер сайта -->
        <p>&copy; 2023 Мой учебный сайт</p>
    </footer>
</body>
</html>
